<script>
import outMain from "@/components/outMain.vue";
import { ElMessage, ElMessageBox } from "element-plus";
import { interviewRecord } from "@/http/api";

export default {
  components: { outMain },
  name: "",
  data() {
    return {
      tableData: [],
      comArr: [],
      statusArr: [
        { label: "全部", value: "" },
        { label: "面试中", value: "1" },
        { label: "面试成功", value: "2" },
        { label: "面试失败", value: "3" },
      ],
      queryData: {
        enterprise_name: "",
        b_real_name: "",
        interview_status: "",
        page: 1,
        per_page: 10,
      },
      total: 0,
    };
  },
  props: {},
  setup() {},
  methods: {
    detailFn(row) {
      this.$router.push({
        path: "/salaInteviewDetail",
        query: { id: row.invite_interview_id, page: this.queryData.page },
      });
    },
    async getData() {
      const { data } = await interviewRecord(this.queryData);
      if (data.code == 1) {
        this.tableData = data.data.data;
        this.total = data.data.total;
      }
    },
  },
  mounted() {},
  async created() {
    this.queryData.page = Number(localStorage.getItem("boot_page")) || 1;

    this.comArr = await this.$getCate.getComList();

    this.getData();
  },
};
</script>
<template>
  <outMain>
    <div class="tableCont">
      <div class="tableName flexCont">
        <div>船员面试记录（{{ total }}）</div>
      </div>
      <div class="tableSerch">
        <div class="serchLeft"></div>
        <div class="serchRight">
          <el-form class="flexCenter" :inline="true">
            <el-form-item>
              <el-select
                v-model="queryData.enterprise_name"
                filterable
                clearable
                @change="getData"
                placeholder="请输入来源企业"
              >
                <el-option
                  v-for="item in comArr"
                  :key="item.enterprise_id"
                  :label="item.enterprise_name"
                  :value="item.enterprise_name"
                />
              </el-select>
            </el-form-item>
            <el-form-item>
              <el-input
                clearable
                @clear="getData"
                @keyup.enter="getData"
                v-model="queryData.b_real_name"
                placeholder="请输入船员姓名"
              />
            </el-form-item>
            <el-form-item>
              <el-select
                v-model="queryData.interview_status"
                clearable
                @change="getData"
                placeholder="请选择面试状态"
              >
                <el-option
                  v-for="item in statusArr"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>
            <btn value="搜索" @click="getData"></btn>
          </el-form>
        </div>
      </div>
      <el-table class="tableMain" :data="tableData" stripe style="width: 100%">
        <el-table-column width="180" show-overflow-tooltip label="来源企业">
          <template #default="{ row }">
            {{ row.enterprise_name }}
          </template>
        </el-table-column>
        <el-table-column
          prop="b_real_name"
          show-overflow-tooltip
          label="船员姓名"
        >
          <template #default="{ row }">
            {{ row.b_real_name }}
          </template>
        </el-table-column>
        <el-table-column
          prop="position_name"
          show-overflow-tooltip
          label="面试岗位"
        >
          <template #default="{ row }">
            {{ row.position_name }}
          </template>
        </el-table-column>
        <el-table-column
          width="140"
          prop="interview_time"
          show-overflow-tooltip
          label="面试时间"
        />
        <el-table-column
          width="180"
          prop="p_enterprise_name"
          show-overflow-tooltip
          label="面试公司"
        >
          <template #default="{ row }">
            {{ row.p_enterprise_name }}
          </template>
        </el-table-column>
        <el-table-column show-overflow-tooltip label="面试状态">
          <template #default="{ row }">
            <div class="tagGroup">
              <el-tag v-if="row.interview_status == 1">面试中</el-tag>
              <el-tag type="success" v-if="row.interview_status == 2"
                >面试成功</el-tag
              >
              <el-tag type="danger" v-if="row.interview_status == 3"
                >面试失败</el-tag
              >
            </div>
          </template>
        </el-table-column>
        <el-table-column
          prop="create_time"
          width="180"
          show-overflow-tooltip
          label="创建时间"
        />
        <el-table-column prop="Name" width="60" label="操作">
          <template #default="{ row }">
            <div class="tableCtrl">
              <div class="greenText ctrlText" @click="detailFn(row)">详情</div>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <div class="pageCont">
        <el-pagination
          v-model:currentPage="queryData.page"
          v-model:page-size="queryData.per_page"
          background
          layout="total, prev, pager, next, jumper"
          :total="total"
          @size-change="getData"
          @current-change="getData"
        />
      </div>
    </div>
  </outMain>
</template>
<style scoped lang="less"></style>
